//
// Created by wxd on 2025/7/6.
//

#pragma once
#include <cstdint>

// 引擎窗口状态监听
class IApplication {
public:
    virtual ~IApplication() = default;
    virtual void initWindowConfig(int major, int minor, int profile, uint32_t width, uint32_t height, const char *title) = 0;
    virtual bool init() = 0;
    virtual bool update() = 0;
    virtual void destroy() = 0;
};

/**
 * 窗口事件类型
 */
enum class WindowEvent {
    NONE,
    RESIZE,                     // 窗口size变化
    KEYBOARD,                   // 键盘监听
    MOUSE_MOVE,                 // 鼠标移动
    MOUSE_SCROLL,               // 鼠标滚轮
    MOUSE_DOWN,                 // 鼠标按键
};


/**
 * 引擎窗口事件监听，下面定义具体回调函数指针, 兼容C++17以上以及以下
 */
#if __cplusplus >= 201703L // 检查当前C++版本是否大于等于17， 大于等于C++17的版本，基于std::function + std::optional + lambda的方式实现函数指针
#include <functional>
#include <optional>

using onResizeCallback = std::optional<std::function<void(int, int)>>;                      // 窗口大小变换监听
using onKeyBoardCallback = std::optional<std::function<void(int, int, int)>>;               // 键盘监听回调
using onMouseCallback = std::optional<std::function<void(int, int, int)>>;                  // 鼠标监听回调
using onCursorCallback = std::optional<std::function<void(double, double)>>;                // 鼠标光标位置回调
using onMouseScrollCallback = std::optional<std::function<void(double, double)>>;           // 鼠标滚轮回到

#else   // 小于C++17的版本，使用传统的方式定义函数指针

using onResizeCallback = void(*) (int width, int height);
using onKeyBoardCallback = void(*) (int key, int action, int mods);
using onMouseCallback = void(*) (int button, int action, int mods);
using onCursorCallback = void(*) (double xpos, double ypos);
using onMouseScrollCallback = void(*) (double xOffset, double yOffset);

#endif

